package com.lp.product.message;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LIPENGAK
 * @Description: 类描述
 * @date 2018-11-30 00:39
 */
@RestController
@RequestMapping("/msg")
@EnableBinding(MsgSource.class)
public class MessageSenderController {

    @Autowired
    @Qualifier("output")
    MessageChannel output;

    @GetMapping("/send/{msg}")
    public String sender(@PathVariable("msg") String msg){
        output.send(MessageBuilder.withPayload(msg).build());
        return "success";
    }

}
